/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sisgeroupas.view;

import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import sisgeroupas.dao.FornecedorDao;
import sisgeroupas.model.ModelFornecedor;
import sisgeroupas.model.TableModelFornecedor;

/**
 *
 * @author Frederico Ribeiro
 */
public class FrmIntFornecedor extends javax.swing.JInternalFrame {
    TableModelFornecedor modelo = new TableModelFornecedor();
    /**
     * Creates new form FrmIntFornecedor
     */
    public static boolean fornecedorAlterado = false;
    public FrmIntFornecedor() {
        initComponents();
        lblId.setVisible(false);
        
        
        //Criando a jTable fornecedor na aba Buscar
        modelo = new TableModelFornecedor();
        tblFornecedor.setModel(modelo);//Esse modelo que passo como parâmetro e feito em TableModelFornecedor.java
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tbpFornecedor = new javax.swing.JTabbedPane();
        pnlPrincipal = new javax.swing.JPanel();
        pnlFornecedor = new javax.swing.JPanel();
        txtRazaoSocial = new javax.swing.JTextField();
        lblId = new javax.swing.JLabel();
        lblRazaoSocial = new javax.swing.JLabel();
        btnLimpar = new javax.swing.JButton();
        btnAlterar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        txtNomeFantasia = new javax.swing.JTextField();
        lblNomeFantasia = new javax.swing.JLabel();
        lblTelefone = new javax.swing.JLabel();
        txtSite = new javax.swing.JTextField();
        lblSite = new javax.swing.JLabel();
        txtTelefone = new javax.swing.JTextField();
        lblCnpj = new javax.swing.JLabel();
        fmtCnpj = new javax.swing.JFormattedTextField();
        pnlPrincipalBuscar = new javax.swing.JPanel();
        pnlBuscar = new javax.swing.JPanel();
        lblBuscar = new javax.swing.JLabel();
        btnBuscar = new javax.swing.JButton();
        txtBuscar = new javax.swing.JTextField();
        scpFornecedor = new javax.swing.JScrollPane();
        tblFornecedor = new javax.swing.JTable();
        btnSelecionar = new javax.swing.JButton();
        btnLimparBusca = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);
        setTitle("Fornecedores");

        pnlFornecedor.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lblRazaoSocial.setText("Razão Social:");

        btnLimpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/817_32x32.png"))); // NOI18N
        btnLimpar.setText("Limpar");
        btnLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimparActionPerformed(evt);
            }
        });

        btnAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/1957_32x32.png"))); // NOI18N
        btnAlterar.setText("Alterar");
        btnAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAlterarActionPerformed(evt);
            }
        });

        btnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/7898_32x32.png"))); // NOI18N
        btnExcluir.setText("Excluir");
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/6228_32x32.png"))); // NOI18N
        btnSalvar.setText("Salvar");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        lblNomeFantasia.setText("Nome Fantasia:");

        lblTelefone.setText("Telefone:");

        lblSite.setText("Site:");

        lblCnpj.setText("CNPJ");

        try {
            fmtCnpj.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###/####-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        javax.swing.GroupLayout pnlFornecedorLayout = new javax.swing.GroupLayout(pnlFornecedor);
        pnlFornecedor.setLayout(pnlFornecedorLayout);
        pnlFornecedorLayout.setHorizontalGroup(
            pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFornecedorLayout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlFornecedorLayout.createSequentialGroup()
                        .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblCnpj)
                            .addComponent(fmtCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlFornecedorLayout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addComponent(lblTelefone))
                            .addGroup(pnlFornecedorLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(txtTelefone, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE))))
                    .addComponent(txtNomeFantasia)
                    .addComponent(txtSite)
                    .addComponent(lblSite)
                    .addComponent(lblNomeFantasia)
                    .addGroup(pnlFornecedorLayout.createSequentialGroup()
                        .addComponent(btnLimpar)
                        .addGap(18, 18, 18)
                        .addComponent(btnAlterar)
                        .addGap(18, 18, 18)
                        .addComponent(btnExcluir)
                        .addGap(18, 18, 18)
                        .addComponent(btnSalvar))
                    .addGroup(pnlFornecedorLayout.createSequentialGroup()
                        .addComponent(lblRazaoSocial)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblId))
                    .addComponent(txtRazaoSocial))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlFornecedorLayout.setVerticalGroup(
            pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFornecedorLayout.createSequentialGroup()
                .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblRazaoSocial)
                    .addComponent(lblId))
                .addGap(8, 8, 8)
                .addComponent(txtRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblNomeFantasia)
                .addGap(5, 5, 5)
                .addComponent(txtNomeFantasia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlFornecedorLayout.createSequentialGroup()
                        .addComponent(lblCnpj)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(fmtCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlFornecedorLayout.createSequentialGroup()
                        .addComponent(lblTelefone)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(14, 14, 14)
                .addComponent(lblSite)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtSite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addGroup(pnlFornecedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLimpar)
                    .addComponent(btnAlterar)
                    .addComponent(btnExcluir)
                    .addComponent(btnSalvar))
                .addGap(23, 23, 23))
        );

        javax.swing.GroupLayout pnlPrincipalLayout = new javax.swing.GroupLayout(pnlPrincipal);
        pnlPrincipal.setLayout(pnlPrincipalLayout);
        pnlPrincipalLayout.setHorizontalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlPrincipalLayout.setVerticalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tbpFornecedor.addTab("Fornecedor", pnlPrincipal);

        pnlBuscar.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lblBuscar.setText("Buscar Fornecedor");

        btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/lupa2_32x32.png"))); // NOI18N
        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        tblFornecedor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        scpFornecedor.setViewportView(tblFornecedor);

        btnSelecionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/check2_32x32.png"))); // NOI18N
        btnSelecionar.setText("Selecionar");
        btnSelecionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelecionarActionPerformed(evt);
            }
        });

        btnLimparBusca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sisgeroupas/icones/817_32x32.png"))); // NOI18N
        btnLimparBusca.setText("Limpar");
        btnLimparBusca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimparBuscaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBuscarLayout = new javax.swing.GroupLayout(pnlBuscar);
        pnlBuscar.setLayout(pnlBuscarLayout);
        pnlBuscarLayout.setHorizontalGroup(
            pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscarLayout.createSequentialGroup()
                .addGroup(pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(pnlBuscarLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSelecionar)
                        .addGap(36, 36, 36)
                        .addComponent(btnLimparBusca))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlBuscarLayout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addGroup(pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(scpFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblBuscar)
                            .addGroup(pnlBuscarLayout.createSequentialGroup()
                                .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnBuscar)))))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        pnlBuscarLayout.setVerticalGroup(
            pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblBuscar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBuscar))
                .addGap(18, 18, 18)
                .addComponent(scpFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pnlBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSelecionar)
                    .addComponent(btnLimparBusca))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlPrincipalBuscarLayout = new javax.swing.GroupLayout(pnlPrincipalBuscar);
        pnlPrincipalBuscar.setLayout(pnlPrincipalBuscarLayout);
        pnlPrincipalBuscarLayout.setHorizontalGroup(
            pnlPrincipalBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalBuscarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlBuscar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlPrincipalBuscarLayout.setVerticalGroup(
            pnlPrincipalBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalBuscarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        tbpFornecedor.addTab("Buscar", pnlPrincipalBuscar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbpFornecedor)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tbpFornecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimparActionPerformed
       limparFornecedor();
       habilitaCampos();
       
    }//GEN-LAST:event_btnLimparActionPerformed

    private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlterarActionPerformed
        habilitaCampos();
        fornecedorAlterado=true;
    }//GEN-LAST:event_btnAlterarActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        if(fornecedorAlterado == true){//Atualiza
            ModelFornecedor fornecedor = new ModelFornecedor();
            fornecedor.setId(Integer.parseInt(lblId.getText()));
            fornecedor.setRazaoSocial(txtRazaoSocial.getText());
            fornecedor.setNomeFantasia(txtNomeFantasia.getText());
            fornecedor.setCnpj(fmtCnpj.getText());
            fornecedor.setTelefone(txtTelefone.getText());
            fornecedor.setSite(txtSite.getText());

            FornecedorDao dao = new FornecedorDao();
            dao.atualizar(fornecedor);
            fornecedorAlterado = false;
            JOptionPane.showMessageDialog(null,"Fornecedor atualizado com sucesso!");
            desabilitaCampos();
        
        }
        else{//Salva
                ModelFornecedor fornecedor = new ModelFornecedor();
                //fornecedor.setId(Integer.parseInt(lblId.getText()));
                fornecedor.setRazaoSocial(txtRazaoSocial.getText());
                fornecedor.setNomeFantasia(txtNomeFantasia.getText());
                fornecedor.setCnpj(fmtCnpj.getText());
                fornecedor.setTelefone(txtTelefone.getText());
                fornecedor.setSite(txtSite.getText());

                FornecedorDao dao = new FornecedorDao();
                dao.inserir(fornecedor);
                JOptionPane.showMessageDialog(null,"Fornecedor Salvo com sucesso!");
            }
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        int resposta = JOptionPane.showConfirmDialog(null,"Tem certeza que deseja excluir o Fornecedor?");
        if(resposta == JOptionPane.YES_OPTION)
        {
        
                ModelFornecedor fornecedor = new ModelFornecedor();
                fornecedor.setId(Integer.parseInt(lblId.getText()));
                fornecedor.setRazaoSocial(txtRazaoSocial.getText());
                fornecedor.setNomeFantasia(txtNomeFantasia.getText());
                fornecedor.setCnpj(fmtCnpj.getText());
                fornecedor.setTelefone(txtTelefone.getText());
                fornecedor.setSite(txtSite.getText());

                FornecedorDao dao = new FornecedorDao();
                dao.apagar(fornecedor);
                JOptionPane.showMessageDialog(null,"Fornecedor apagado com sucesso!");
                limparFornecedor();
                habilitaCampos();
        }
    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
         ModelFornecedor fornecedor = new ModelFornecedor();

        fornecedor.setNomeFantasia(txtBuscar.getText());

        FornecedorDao dao = new FornecedorDao();

        if(!dao.pesquisar(fornecedor).isEmpty()){//Verifica se a pesquisa vai retorna diferente de vazio
            ArrayList <ModelFornecedor> ResFornecedor =  dao.pesquisar(fornecedor);
            
            for(int i=0; i < ResFornecedor.size();i++)
            {
                
                modelo.addCadastro(ResFornecedor.get(i));
            }
        }else {
            JOptionPane.showMessageDialog(null,"Não foi encontrado nenhum resultado!");
        }
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnLimparBuscaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimparBuscaActionPerformed
        txtBuscar.setText("");
        modelo.limpar();
    }//GEN-LAST:event_btnLimparBuscaActionPerformed

    private void btnSelecionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelecionarActionPerformed
        int linhaSel = tblFornecedor.getSelectedRow();
        int colunaSel = tblFornecedor.getSelectedColumn();

        ModelFornecedor fornecedor= modelo.getFornecedor(linhaSel);
        //JOptionPane.showMessageDialog(null,"Cadastro: " + cadastro.getNome());
        //modelo.getValueAt(int coluna, int linha);
        txtBuscar.setText("");
        modelo.limpar();

        lblId.setText(String.valueOf(fornecedor.getId()));//Coloca a valor do id em um label oculto
        txtRazaoSocial.setText(fornecedor.getRazaoSocial());
        txtNomeFantasia.setText(fornecedor.getNomeFantasia());
        fmtCnpj.setText(fornecedor.getCnpj());
        txtTelefone.setText(fornecedor.getTelefone());
        txtSite.setText(fornecedor.getSite());
        tbpFornecedor.setSelectedIndex(0);//Muda o foco da aba
        desabilitaCampos();
    }//GEN-LAST:event_btnSelecionarActionPerformed

    public void desabilitaCampos(){
        txtRazaoSocial.setEnabled(false);
        txtNomeFantasia.setEnabled(false);
        fmtCnpj.setEnabled(false);
        txtTelefone.setEnabled(false);
        txtSite.setEnabled(false);
        
    }
    
    public void limparFornecedor(){
       txtRazaoSocial.setText("");
       txtNomeFantasia.setText("");
       fmtCnpj.setText("");
       txtTelefone.setText("");
       txtSite.setText("");
    }
    
    public void habilitaCampos(){
        txtRazaoSocial.setEnabled(true);
        txtNomeFantasia.setEnabled(true);
        fmtCnpj.setEnabled(true);
        txtTelefone.setEnabled(true);
        txtSite.setEnabled(true);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAlterar;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnLimpar;
    private javax.swing.JButton btnLimparBusca;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JButton btnSelecionar;
    private javax.swing.JFormattedTextField fmtCnpj;
    private javax.swing.JLabel lblBuscar;
    private javax.swing.JLabel lblCnpj;
    private javax.swing.JLabel lblId;
    private javax.swing.JLabel lblNomeFantasia;
    private javax.swing.JLabel lblRazaoSocial;
    private javax.swing.JLabel lblSite;
    private javax.swing.JLabel lblTelefone;
    private javax.swing.JPanel pnlBuscar;
    private javax.swing.JPanel pnlFornecedor;
    private javax.swing.JPanel pnlPrincipal;
    private javax.swing.JPanel pnlPrincipalBuscar;
    private javax.swing.JScrollPane scpFornecedor;
    private javax.swing.JTable tblFornecedor;
    private javax.swing.JTabbedPane tbpFornecedor;
    private javax.swing.JTextField txtBuscar;
    private javax.swing.JTextField txtNomeFantasia;
    private javax.swing.JTextField txtRazaoSocial;
    private javax.swing.JTextField txtSite;
    private javax.swing.JTextField txtTelefone;
    // End of variables declaration//GEN-END:variables
    
    
    public void setPosicao() {  
            Dimension d = this.getDesktopPane().getSize();  
            this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2); }  
}